
package com.jf.cloud.product.controller.multishop;

import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.common.product.vo.GiveawaySpuVO;
import com.jf.cloud.common.product.vo.SpuVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.common.security.AuthUserContext;
import com.jf.cloud.product.dto.GiveawaySpuDTO;
import com.jf.cloud.product.service.GiveawaySpuService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 赠品套装商品项
 *
 * @author zz
 * @date 2022-08-16 11:11:59
 */
@RestController("multishopGiveawaySpuController")
@RequestMapping("/m/giveaway_spu")
@Tag(name = "赠品套装商品项")
public class GiveawaySpuController {

    @Autowired
    private GiveawaySpuService giveawaySpuService;

    @GetMapping("/page")
    @Operation(summary = "获取赠品套装商品项列表" , description = "分页获取赠品套装商品项列表")
    public ServerResponseEntity<PageVO<GiveawaySpuVO>> page(@Valid PageDTO pageDTO) {
        PageVO<GiveawaySpuVO> giveawaySpuPage = giveawaySpuService.page(pageDTO);
        return ServerResponseEntity.success(giveawaySpuPage);
    }

    @GetMapping("/mainSpuPage" )
    @Operation(summary = "分页获取主赠送商品" , description = "分页获取赠品信息")
    public ServerResponseEntity<PageVO<SpuVO>> getByGiveawaySpuId(@Valid PageDTO pageDTO, @ParameterObject GiveawaySpuDTO giveawaySpuDTO) {
        Long shopId = AuthUserContext.get().getTenantId();
        giveawaySpuDTO.setShopId(shopId);
        PageVO<SpuVO> mainSpuPage = giveawaySpuService.getMainSpuPage(pageDTO, giveawaySpuDTO);
        return ServerResponseEntity.success(mainSpuPage);
    }


}
